<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>libwebsockets: Network related helper APIs</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="libwebsockets.org-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libwebsockets
   </div>
   <div id="projectbrief">Lightweight C library for HTML5 websockets</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__net.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Network related helper APIs</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gad0df22db2be9fc65a667a1e83f9a92a4"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN const char *LWS_WARN_UNUSED_RESULT&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__net.html#gad0df22db2be9fc65a667a1e83f9a92a4">lws_canonical_hostname</a> (struct lws_context *context)</td></tr>
<tr class="separator:gad0df22db2be9fc65a667a1e83f9a92a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga092e5f473b3347f03ffeef8a950080f3"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__net.html#ga092e5f473b3347f03ffeef8a950080f3">lws_get_peer_addresses</a> (struct lws *wsi, lws_sockfd_type fd, char *name, int name_len, char *rip, int rip_len)</td></tr>
<tr class="separator:ga092e5f473b3347f03ffeef8a950080f3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad01014fed09759741b6d23afccfdaacc"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__net.html#gad01014fed09759741b6d23afccfdaacc">lws_get_peer_simple</a> (struct lws *wsi, char *name, int namelen)</td></tr>
<tr class="separator:gad01014fed09759741b6d23afccfdaacc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga869d8bdffb0f2a7ce08e3ce10d6be3d8"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__net.html#ga869d8bdffb0f2a7ce08e3ce10d6be3d8">lws_interface_to_sa</a> (int ipv6, const char *ifname, struct sockaddr_in *addr, size_t addrlen)</td></tr>
<tr class="separator:ga869d8bdffb0f2a7ce08e3ce10d6be3d8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<h2>Network related helper APIs</h2>
<p>These wrap miscellaneous useful network-related functions </p>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="gad0df22db2be9fc65a667a1e83f9a92a4"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN const char* LWS_WARN_UNUSED_RESULT lws_canonical_hostname </td>
          <td>(</td>
          <td class="paramtype">struct lws_context *&#160;</td>
          <td class="paramname"><em>context</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__net.html#gad0df22db2be9fc65a667a1e83f9a92a4">lws_canonical_hostname()</a> - returns this host's hostname</p>
<p>This is typically used by client code to fill in the host parameter when making a client connection. You can only call it after the context has been created.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">context</td><td>Websocket context </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga092e5f473b3347f03ffeef8a950080f3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN void lws_get_peer_addresses </td>
          <td>(</td>
          <td class="paramtype">struct lws *&#160;</td>
          <td class="paramname"><em>wsi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">lws_sockfd_type&#160;</td>
          <td class="paramname"><em>fd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>name_len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>rip</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>rip_len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__net.html#ga092e5f473b3347f03ffeef8a950080f3">lws_get_peer_addresses()</a> - Get client address information </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">wsi</td><td>Local struct lws associated with </td></tr>
    <tr><td class="paramname">fd</td><td>Connection socket descriptor </td></tr>
    <tr><td class="paramname">name</td><td>Buffer to take client address name </td></tr>
    <tr><td class="paramname">name_len</td><td>Length of client address name buffer </td></tr>
    <tr><td class="paramname">rip</td><td>Buffer to take client address IP dotted quad </td></tr>
    <tr><td class="paramname">rip_len</td><td>Length of client address IP buffer <pre class="fragment"> This function fills in name and rip with the name and IP of
 the client connected with socket descriptor fd.  Names may be
 truncated if there is not enough room.  If either cannot be
 determined, they will be returned as valid zero-length strings.</pre> </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gad01014fed09759741b6d23afccfdaacc"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN const char* lws_get_peer_simple </td>
          <td>(</td>
          <td class="paramtype">struct lws *&#160;</td>
          <td class="paramname"><em>wsi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>namelen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__net.html#gad01014fed09759741b6d23afccfdaacc">lws_get_peer_simple()</a> - Get client address information without RDNS</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">wsi</td><td>Local struct lws associated with </td></tr>
    <tr><td class="paramname">name</td><td>Buffer to take client address name </td></tr>
    <tr><td class="paramname">namelen</td><td>Length of client address name buffer</td></tr>
  </table>
  </dd>
</dl>
<p>This provides a 123.123.123.123 type IP address in name from the peer that has connected to wsi </p>

</div>
</div>
<a class="anchor" id="ga869d8bdffb0f2a7ce08e3ce10d6be3d8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN int lws_interface_to_sa </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ipv6</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>ifname</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct sockaddr_in *&#160;</td>
          <td class="paramname"><em>addr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>addrlen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__net.html#ga869d8bdffb0f2a7ce08e3ce10d6be3d8">lws_interface_to_sa()</a> - Convert interface name or IP to sockaddr struct</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ipv6</td><td>Allow IPV6 addresses </td></tr>
    <tr><td class="paramname">ifname</td><td>Interface name or IP </td></tr>
    <tr><td class="paramname">addr</td><td>struct sockaddr_in * to be written </td></tr>
    <tr><td class="paramname">addrlen</td><td>Length of addr</td></tr>
  </table>
  </dd>
</dl>
<p>This converts a textual network interface name to a sockaddr usable by other network functions </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
